﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TLD_Vision.filters
{
    public class Noise
    {
        public static SinglePixelOperation Impulse(int threshold)
        {
            Random rand = new Random();

            return delegate(uint argb)
            {
                return rand.Next(0, 100) < threshold ? 0xffffffff : argb;
            };
        }

        public static SinglePixelOperation SaltAndPepper(int threshold)
        {
            Random rand = new Random();

            return delegate(uint argb)
            {
                if (rand.Next(0, 100) < threshold)
                    return 0xffffffff;
                else if (rand.Next(0, 100) < threshold)
                    return 0xff000000;
                return argb;
            };
        }
    }
}
